package com.aurora.source.center.presenter;

import android.content.Context;
import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.center.bean.AddBatchBean;
import com.aurora.source.center.view.IAddBatchView;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.util.Map;

public class AddBatchPresenter extends BasePresenter<IAddBatchView> {

    public AddBatchPresenter(IAddBatchView baseView) {
        super(baseView);
    }


    public void addBAtch(Context context, Map<String, String> params) {
        requestMethod.addBatch(params, new SubscriberObserver<BaseBean<AddBatchBean>>(context,"正在添加...") {
            @Override
            public void onSuccess(BaseBean<AddBatchBean> addBatchBeanBaseBean) {
                if (addBatchBeanBaseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)) {
                    baseView.onAddBatchSuccess(addBatchBeanBaseBean.getMsg());
                } else {
                    baseView.onAddBatchFail(addBatchBeanBaseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onAddBatchFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
